package com.ryx.controller;

import com.ryx.aop.annotation.MyLog;
import com.ryx.entity.SysLog;
import com.ryx.service.LogService;
import com.ryx.utils.DataResult;
import com.ryx.vo.req.SysLogPageReqVo;
import com.ryx.vo.resp.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongsPackage: com.ryx.controller
 * @Author: 容永轩
 * @CreateTime: 2021-01-14
 * @Description:
 */
@RestController
@RequestMapping("/api")
@Api(tags = "系统管理-日志管理",description = "日志管理相关接口")
public class LogController {

    @Autowired
    private LogService logService;

    @PostMapping("/logs")
    @ApiOperation(value = "分页查找操作日志接口")
    @RequiresPermissions("sys:log:list")
    public DataResult<PageVo<SysLog>> pageLogs(@RequestBody SysLogPageReqVo vo){

        DataResult<PageVo<SysLog>> result = DataResult.success();
        result.setData(logService.pageInfo(vo));
        return  result;
    }

    @DeleteMapping("/log")
    @ApiOperation(value = "删除日志接口")
    @MyLog(title = "系统管理-日志管理",action = "删除日志接口")
    @RequiresPermissions("sys:log:delete")
    public DataResult deleteLog(@RequestBody @ApiParam(value = "日志id集合") List<String> logIds){
        logService.deletedLog(logIds);

        return DataResult.success();
    }
}
